<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="../../css/allBase.css">
		<link rel="stylesheet" href="../../css/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" href="../../css/tables.css">
		<link rel="stylesheet" href="../../css/dialog.css" />
        <link href="../../js/riqi/bootstrap.min.css" rel="stylesheet">
        <link href="../../js/riqi/font-awesome.min.css" rel="stylesheet">
        <link rel="stylesheet" type="text/css" media="all" href="../../js/riqi/daterangepicker-bs3.css" />
		<style>
			#main1 canvas {
				width: 500px;
			}
			
			#main1 {
				position: absolute;
				top: 44%;
				display: inline-block;
			}
			
			#main {
				position: absolute;
				top: 44%;
				right: 10%;
			}
			.timerow td{
				text-align: center!important;
			}
			td:last-child{
				/*border-right:1px solid #ddd!important;*/
			}
			.mt-20{
				padding-left: 50px;
				padding-right: 50px;
			}
			.tableBox{
				padding-top: 10px;
			    padding-bottom: 10px;
			    margin-left: 2%;
			    margin: 2% auto;
			    width: 97%;
			    /*min-height: 550px;*/
			    background-color: #fff;
			    box-shadow: 3px 3px 20px 3px #ddd;
			}
			.text-c{
				background: #55bde4;
				
			}
			.timerow td {
			    background: #fdfdfd!important;
			    color: #313B4B!important;
			    font-weight: 400!important;
			}
			.text-c td{
				color:#fff;
			}
			
		</style>
		<![endif]-->
    <title>结果</title>

</head>
<body>
	<div class="classifiedBox">
	    <div class="classified-search">
            <form class="form-horizontal" style="margin-bottom: 5px;">
                <fieldset>
                	<div class="control-group">
                		<div class="controls">
	                    	<p style="float: left;line-height: 34px;">日期范围：</p>
	                     	<div class="input-prepend input-group" style="float: left;width:150px ;">
	                     
		                     	<span class="add-on input-group-addon">
		                     		<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
		                     	</span>
		                     	<input type="text" readonly style="width: 200px" name="reservation" id="reservation" class="form-control" value="2017-7-21 - 2017-7-21" /> 
	                   		</div>
                    		<p class="meici" style="float:left;color:red;line-height: 34px;">（每次最多选取60天）</p>
                    	</div>
                  	</div>
                </fieldset>
            </form>
	    <button id="btncx" onclick="" class="btn btn-success" type="submit">开始查询</button>
	    </div>
	</div>
    <!--数据展示结果-->
    <img class="loadingimg" src="../../img/loading.gif" style="position: absolute; top: 0%; left: 0; right: 0; bottom: 0; margin: auto;display: none;" />
    <div class="tableBox" style="display: none;">
    	<div class="mt-20">
			<table id="reptable1" class="table table-border table-bordered table-bg table-hover table-sort" cellspacing="0" cellpadding="0">
				<thead class="thead1" >
					
				</thead>
				
			</table>
	    </div>
    </div>
    
    <script src="../../js/jquery/jQuery-2.2.0.min.js"></script>
    <!--<script src="../js/charts/Chart.js"></script>-->
    <script type="text/javascript" src="../../js/base/echarts.common.min.js"></script>
    <script type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../js/base/ajax.js"></script>
    <!--<script type="text/javascript" src="../../js/base/yingSoftSetTest.js"></script>-->
    <script type="text/javascript" src="../../js/base/yingSoftPrg.js"></script>
	<script type="text/javascript" src="../../js/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="../../js/base/dialog.js"></script>
	
	 <script type="text/javascript" src="../../js/riqi/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../js/riqi/moment.js"></script>
    <script type="text/javascript" src="../../js/riqi/daterangepicker.js"></script>
    <script type="text/javascript">
    	 var myDate = new Date();//添加日期
               	y=myDate.getFullYear(); 
               	m=myDate.getMonth()+1;
               	d=myDate.getDate()-1;
               	if(myDate.getDate()==1){
               		 d=myDate.getDate();
               	}
               	var isClick = true;
               	dqy=y+"-"+m+"-"+d;
               	$('#reservation').val(dqy+" - "+dqy)
               $(document).ready(function() {
                  $('#reservation').daterangepicker({
                        // startDate: moment().startOf('day'),  
                        //endDate: moment(),  
                        //minDate: '01/01/2012',    //最小时间  
                        maxDate : moment(), //最大时间   
                        dateLimit : {  
                            days : 60  
                        }, //起止时间的最大间隔  
                        showDropdowns : true,  
                        showWeekNumbers : false, //是否显示第几周  
                        timePicker : false, //是否显示小时和分钟  
                        timePickerIncrement : 60, //时间的增量，单位为分钟  
                        timePicker12Hour : false, //是否使用12小时制来显示时间  
                        ranges : {  
                            //'最近1小时': [moment().subtract('hours',1), moment()],  
                            '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
                            '最近7日': [moment().subtract('days', 6), moment()],
                            '最近30日': [moment().subtract('days', 29), moment()],  
                            '最近60日': [moment().subtract('days', 59), moment()]  
                        },  
                        opens : 'right', //日期选择框的弹出位置  
                        buttonClasses : [ 'btn btn-default' ],  
                        applyClass : 'btn-small btn-primary blue',  
                        cancelClass : 'btn-small',  
                        format : 'YYYY-MM-DD', //控件中from和to 显示的日期格式  
                        separator : ' - ',  
                        locale : {  
                            applyLabel : '确定',  
                            cancelLabel : '取消',  
                            fromLabel : '从',  
                            toLabel : '到',  
                            weekLabel: 'W',
                            customRangeLabel : '选择时间',  
                            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],  
                            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',  
                                    '七月', '八月', '九月', '十月', '十一月', '十二月' ]
//                          firstDay : 1  
                        }  
                    }, function(start, end, label) {//格式化日期显示框  
                        $('#reservation span').html(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));  
                    }); 
					
               });
               $(document).on('click','.applyBtn',function(){//判断日期是否是在60天之内
               	     var val=$('#reservation').val().split(' - ');
                  	 var endTime=new Date(val[1]);
                  	 var startTime=new Date(val[0]);
                  	if(endTime - startTime>5270400000){
                  		$('.daterangepicker').css('display','block')
                  		 G_Prg.alert('每次最多选取60天',function(){
		
	                    });
                  	}
                })
        this.init = function(){
            var option = {};
            var dd=new Date();
            var m=dd.getMonth()+1;
            var d1=dd.getDate();
            //var d2=dd.getDate();
            var days1=G_Prg.GetDay(dd.getFullYear(),m,d1);
            var days2=  dd.getFullYear()+'-'+m+'-'+d1;
            $('#logmin').val(days1);
            $('#logmax').val(days1);
            allclick();//点击事件
        }
        /**************************************************
         * 功能：点击事件
         * 函数名：allclick（）
         * 传入参数：无
         * 创建人：刘淳昊 2017-03-13
         *************************************************/
        function allclick() {
            
            //查询结果
            $('#btncx').on('click',function(){
                var val=$('#reservation').val().split(' - ');
                var startTime=new Date(val[0]);
                var endTime=new Date(val[1]);
                if(endTime-startTime<5270400000){
                    $('.loadingimg').show();
                	$('.panel-body').hide();
                	setTimeout(function(){
                		$('.panel-body').show();
	                    getLoginData();
                	},500)
                }else{
               		G_Prg.alert('每次最多选取60天');
                }
              
            })

        }
            
        /**************************************************
         * 功能：答题详情数据 /api/questions/getTestQuestionsListMing
         * 函数名：getLoginData（）
         * 传入参数：startDay    开始时间
         *         endDay      结束时间
         * 创建人：刘淳昊 2017-08-10
         *************************************************/
        function getLoginData(){
        	var val=$('#reservation').val().split(' - ');
            var startTime = val[0];
            var endTime = val[1];
            var _url='/api/questions/getTestQuestionsListMing?startDay='+startTime+'&endDay='+endTime;
            G_AjaxApi_bj.get(_url,false,function(json){
                var jsonData = JSON.parse(json);

                if(jsonData.status == 200){
                	$('.loadingimg').hide();
                	$('.tableBox').css('display','block');
                	$('.thead1 tr').remove();
					var nowstr = '<tr class="text-c"><td valign="middle" width="10%">提问时间</td><td valign="middle" width="10%">科目</td>'+
					'<td valign="middle" width="10%">用户ID</td><td valign="middle" width="5%">抢答人数</td><td valign="middle" width="25.5%">原题内容</td><td valign="middle" width="10%">提问内容</td><td valign="middle" width="25.5%">详情</td></tr>';
					$('.thead1').append(nowstr);
					var type;
					var timu;
					var selected;
					var SubType;
					var selects;
					var strTr;
					
					for(var i =jsonData.data.length-1;i>=0;i--){
						var testData = JSON.parse(jsonData.data[i].testInfo);
//						jsonData.data[i].testInfo = G_SetTestInfo.replaceImgURL(JSON.parse(jsonData.data[i].testInfo)).StyleItems[0];
						var questionData = testData.StyleItems[0];
						if(questionData.Type == "A3TEST"){
							type = questionData.Type;
							SubType = questionData.SubType;
							timu = questionData.TestItems[0].FrontTitle +questionData.TestItems[0].A3TestItems[0].Title ;
							selected=questionData.TestItems[0].A3TestItems[0].SelectedItems;
							
						}else if(questionData.Type == "BTEST"){
							type = questionData.Type;
							SubType = questionData.SubType;
							timu = questionData.Explain + questionData.TestItems[0].BTestItems[0].Title;
							selected=questionData.TestItems[0].SelectedItems;
						}else {
							type = questionData.Type;
							SubType = questionData.SubType;
							timu = questionData.TestItems[0].Title;
							selected=questionData.TestItems[0].SelectedItems;
						}
						var checkArr = [];
						for(var j=0;j<selected.length;j++){
							selects = selected[j].ItemName+selected[j].Content;
							checkArr.push(selects)
						}
						
						strTr = '';
						strTr= '<tr class="timerow">'+
									'<td valign="middle">'+G_Prg.datetimeFormat(new Date(jsonData.data[i].createTime), 'yyyy-MM-dd') +'</td>'+
									'<td valign="middle">'+jsonData.data[i].appID+'</td><td valign="middle">'+jsonData.data[i].userID+'</td>'+
									'<td valign="middle">'+jsonData.data[i].replyCount+'</td><td valign="middle">'+timu+'<p>'+checkArr+'</td>'+
									'<td valign="middle">'+jsonData.data[i].content+'</td><td valign="middle"><input queid="'+jsonData.data[i].questionID+'" type="button" value="点击查看" id="look_'+i+'"></td>'
									'</tr>';
						$('.text-c').after(strTr);
						clickEvent(i);
					}
					
               }else {
                	$('.loadingimg').hide();
                    $('.tableBox').css('display','none');
                	alert(jsonData.msg);
                	
               }
                   
            })
           
        }
        function clickEvent(index){
        	$('#look_'+index).on('click',function(){
				var _this =getQuestionContent($(this).attr('queid'));
				$(this).hide();
				if(_this.length == 0){
					$(this).after('无人回答此问题')
				}else if(_this.length == 1){
					$(this).after('<p>1.'+_this[0]);
					
				}else if(_this.length == 2){
					$(this).after('<p>1.'+_this[0]+'<p>2.'+_this[1]);
				}else{
					$(this).after('<p>1.'+_this[0]+'<p>2.'+_this[1]+'<p>3.'+_this[2]);
				}
			})
        }
        /**************************************************************
         *功能：获取问题的详情/api/questions/getTestQuestionsDataMing
         * 函数：getQuestionContent
         * 传入参数：questionID
         **************************************************************/
        function getQuestionContent(questionID){
        	isClick = false;
        	var str =[];
        	var _url='/api/questions/getTestQuestionsDataMing?questionID='+questionID;
        	 G_AjaxApi_bj.get(_url,false,function(json){
        	 	var jsonData = JSON.parse(json);
        	 	if(jsonData.status == 200){
        	 		var replyArr = jsonData.data.reply;
        	 		for(var i =0;i<replyArr.length;i++){
        	 			str.push(replyArr[i].content);
        	 		}
        	 		
        	 	}
        	 })
        	 return str;
        }
        init();
    </script>
</body>
</html>